﻿Imports DTO
Imports System.Data.SqlClient
Public Class TyGiaDAO
    Public Shared Function LayDSTyGia() As DataTable
        Dim dt As DataTable
        dt = CKetNoi.GetData("LayDSTyGia")
        Return dt
    End Function

    Public Shared Function ThemTyGia(tygia As TyGiaDTO) As Integer
        Dim kq As Integer

        Dim lst As New List(Of SqlParameter)
        lst.Add(New SqlParameter("@maTyGia", tygia.MaTyGia))
        lst.Add(New SqlParameter("@tenTyGia", tygia.TenTyGia))
        lst.Add(New SqlParameter("@QuyDoi", tygia.TyGiaQuyDoi))
        lst.Add(New SqlParameter("@maTT", tygia.MaTT))

        kq = CKetNoi.ExecQueryStoreProc("ThemTyGia", lst)

        Return kq
    End Function

    Public Shared Function CapNhatTyGia(tygia As TyGiaDTO) As Integer
        Dim kq As Integer

        Dim lst As New List(Of SqlParameter)
        lst.Add(New SqlParameter("@maTyGia", tygia.MaTyGia))
        lst.Add(New SqlParameter("@tenTyGia", tygia.TenTyGia))
        lst.Add(New SqlParameter("@QuyDoi", tygia.TyGiaQuyDoi))
        lst.Add(New SqlParameter("@maTT", tygia.MaTT))

        kq = CKetNoi.ExecQueryStoreProc("CapNhatTyGia", lst)

        Return kq
    End Function

    Public Shared Function XoaTyGia(tygia As TyGiaDTO) As Integer
        Dim kq As Integer
        Dim sql As String = String.Format("delete TyGia where MaTyGia = '{0}'", tygia.MaTyGia)
        kq = CKetNoi.ExecNonQuery(sql)
        Return kq
    End Function

    Public Shared DongKetNoi As SqlConnection = CKetNoi.Connect



End Class
